package net.yx.config;

import net.yx.properties.MinIoProperties;
import net.yx.service.MinIoService;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述：
 *
 * @Author shf
 * @Date 2019/5/7 21:50
 * @Version V1.0
 **/
@Configuration
@EnableConfigurationProperties({MinIoProperties.class})
@ConditionalOnProperty(prefix = "min-io.oss", name = "bucket-name", matchIfMissing = true)
public class MinIoAutoConfiguration {

    @Bean
    public MinIoService minIoService(MinIoProperties minIoProperties) {
        return new MinIoService(minIoProperties.getEndpoint(), minIoProperties.getAccessKey(), minIoProperties.getSecretKey(), minIoProperties.getBucketName());
    }
}
